<template>
	<view class="p-12">
		<view class="position-relative bg-white rounded-8 py-12 px-24 flex flex-x-space-between mb-10 overflow-hidden"
			v-for="(item,index) in list" :kye='index' v-if="list.length>0">
			<view v-if="item.is_vip=='1'"
				class="position-absolute right-0 top-0 fs-12 text-white bg-blue-2 px-8 py-2 rounded-bottom-left-8">VIP
			</view>
			<view class="flex flex-column flex-x-space-between py-1">
				<text class="text-grey-3 fs-16 fw-600 text-spacing-2">
					{{item.name}}
				</text>
				<text class="text-grey-1  fs-12 mt-8">共{{item.number}}题</text>
				<text class="text-grey-1  fs-12 mt-8">答题时间:{{item.time}}分</text>
			</view>
			<view class="flex flex-y-center">
				<view class="px-16 py-6 bg-grey-6 text-grey-4 rounded-30 block fs-14" v-if="item.record_id!=null">答题
				</view>
				<view v-else>
					<view v-if="item.is_vip=='1'&& USERINFO.is_vip=='2'" class="px-16 py-6 bg-blue-1 text-white rounded-30 block fs-14"
						 @click="openPackage()">答题</view>
						
					<view class="px-16 py-6 bg-blue-1 text-white rounded-30 block fs-14"
						@click="$page.open('/pages/topic/topic?type=2&id=' + item.id)"
						v-else>答题</view>
				</view>
			</view>
		</view>

		<y-empty v-if="list.length==0"></y-empty>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { $http, $page } from '@/utils';
	import { onLoad } from '@dcloudio/uni-app'
	import { useWebConfigStore, useRefs, useUserStore } from "@/stores/index";
	const { USERINFO } = useRefs(useUserStore());
	const list = ref([])
	onLoad(() => {
		getList()
	})
	const getList = () => {
		$http.get('TestPaper/getTestPaper').then(res => {
			list.value = res.data
		})
	}
	const openPackage = () => {
		// #ifdef H5
		$page.open('/pages/package/package');
		return;
		// #endif
		if (uni.getSystemInfoSync().platform == 'ios' && WEBCONFIG?.value.ios_pay == '2') {
			activation()
		} else {
			$page.open('/pages/package/package')
		}
	}
</script>

<style>

</style>